package com.stlm2.controller.collections;

import com.stlm2.dems.service.CollectionsService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by apple on 2017/10/16.
 */
@Controller
@RequestMapping("/collectionsC")
public class CollectionsController {
    @Resource
    private CollectionsService collectionsService;


    /**
     * 我的收藏
     * ffl
     * 2017-10-16 13:51:56
     * @param token
     * @param pageNu
     * @return
     */
    @ResponseBody
    @RequestMapping(value="/myCollections.json",produces="application/json;charset=UTF-8")
    public String myCollections(String companyCode,String token,String pageNu){
        return collectionsService.myCollections(token, pageNu);
    }

    /**
     * 添加收藏
     * ffl
     * 2017-10-16 13:36:53
     * @param token
     * @param goodsId
     * @return
     */
    @ResponseBody
    @RequestMapping(value="/addCollections.json",produces="application/json;charset=UTF-8")
    public  String addCollections (String companyCode,String token,String goodsId){
        return collectionsService.addCollections(token, goodsId);
    }

    /**
     * 删除我的收藏
     * ffl
     * 2017-10-16 14:24:33
     * @param token
     * @param idStr
     * @return
     */
    @ResponseBody
    @RequestMapping(value="/delCollections.json",produces="application/json;charset=UTF-8")
    public String deleteById(String companyCode,String token,String idStr){
         return collectionsService.deleteById(token, idStr);
    }

    /**
     * 清空我的收藏
     * ffl
     * 2017-10-16 14:35:25
     * @param token
     * @return
     */
    @ResponseBody
    @RequestMapping(value="/cleanCollections.json",produces="application/json;charset=UTF-8")
    public  String cleanCollection(String companyCode,String token){
        return collectionsService.cleanCollection(token);
    }

    /**
     * 我的收藏 个数
     * ffl
     * 2017-10-16 17:19:44
     * @param token
     * @return
     */
    @ResponseBody
    @RequestMapping(value="/myCollectionsNum.json",produces="application/json;charset=UTF-8")
    public String myCollectionsNum(String companyCode,String token){
        return collectionsService.myCollectionNum(token);
    }
}
